<template>
	<view class="main-box">
		<image class="logo-img" src="/static/launchPic.png"></image>
		<view class="text-box">
			<text class="title-text">开启精彩生活</text>
			<text class="content-text">为你推荐感兴趣的活动，玩出花样</text>
		</view>
	</view>
</template>

<script>
	import Vue from 'vue'
	//import * as jPush from '@/utils/jpush.js'
	
	export default {
		data() {
			return {
				
			};
		},
		onLoad() {
			uni.getSystemInfo({
				success: (res) => {
					Vue.prototype.$safeBottom = res.safeAreaInsets.bottom;
					Vue.prototype.$safeTop = res.safeAreaInsets.top;
				}
			})
		},
		onReady() {
			setTimeout(() => {
				this.init();
			}, 3000)
		},
		methods: {
			init() {
				
				// // 极光推送-打开debug
				// jPush.openDebug()
				
				// // 极光推送-获取rid
				// jPush.getRegistrationID(result => {
				// 	console.log('【业务getRegistrationID】', result)
				
				// })
				
				// jPush.addConnectEventListener(result => {
				// 	console.log('【连接回调】', result)
				// });
				
				// // 极光推送-通知事件回调
				// jPush.addNotificationListener(result => {
				
				// 	console.log('【业务addNotificationListener】', result)
				// })
				
				// // 极光推送-标签别名事件回调
				// jPush.addTagAliasListener(result => {
				// 	console.log('【业务addTagAliasListener】', result)
				// })
				
				// jPush.addLocalNotification({})
				this.loadHistory();
				this.getLocation();
			},
			loadHistory() {
				uni.getStorage({
					key: 'history',
					success: (res) => {
						Vue.prototype.$history = res.data.split(',');
					},
					fail: () => {
						Vue.prototype.$history = [];
					}
				})
			},
			getLocation() {
				uni.getLocation({
					type: 'gcj02',
					geocode: true,
					success: (res) => {
						Vue.prototype.$myLocation = res;
						this.getUserInfo();
					}
				})
			},
			getUserInfo() {
				uni.getStorage({
					key: 'token',
					success: () => {
						this.$apis.getUserInfo({}).then(res => {
							if (res.code === 0) {
								Vue.prototype.$userInfo = res.data;
								uni.redirectTo({
									url: "/pages/index"
								})
							} else {
								uni.redirectTo({
									url: "/pages/oneKeyLogin"
								})
							}
						})
					},
					fail: () => {
						uni.redirectTo({
							url: "/pages/oneKeyLogin"
						})
					}
				})
				
			}
		}
	}
</script>

<style lang="scss">
	.main-box {
		width: 100vw;
		height: 100vh;
		background-color: white;
		display: flex;
		justify-content: center;
		align-items: center;
		
		.logo-img {
			margin-bottom: 250rpx;
		    width: 524rpx;
			height: 482rpx;
		}
		
		.text-box {
			width: 100%;
			position: absolute;
			display: flex;
			flex-direction: column;
			align-items: center;
			bottom: 96rpx;
			
			.title-text {
				font-size: 46rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FF5E2E;
			}
			
			.content-text {
				font-size: 31rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #222222;
				margin-top: 23rpx;
			}
		}
	}
</style>
